package com.mdd.admin.crontab;

import com.mdd.admin.service.backup.IBackUpDataBaseService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.text.SimpleDateFormat;

/**
 * @Description  数据库备份定时任务
 **/
@Component
public class ScheduledTasks {
    private static final Logger log = LoggerFactory.getLogger(ScheduledTasks.class);
    private static final SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMddHHmmssSS");
    @Resource
    private IBackUpDataBaseService iBackUpDataBaseService;

    /**
     * 每天下午4点50分30秒执行
     */
   // 每一分钟执行一次
    @Scheduled(cron="0/1 * * * * ?")
    public void reportCurrentTime() {
        String format = dateFormat.format(System.currentTimeMillis());
        log.info("The time is now {}", format);
        iBackUpDataBaseService.exportSql(format,"3306");
    }
}
